package main

import (
	"fmt"
	"sync"
	"time"
)

type data struct {
	sync.Mutex
	buf [1024]byte
	count int
}

func main()  {
	d := data{}
	d.count =1
	go func() {
		for i:= 0;i<3;i++ {
			d.Lock()
			d.count++
			fmt.Printf("第一个任务%d \n",d.count)
			d.Unlock()
		}
	}()
	go func() {
		for i:= 0;i<3;i++ {
			d.Lock()
			d.count++
			fmt.Printf("第二个任务%d \n",d.count)
			d.Unlock()
		}
	}()
	time.Sleep(time.Second *6)
}
